﻿namespace KeRui.Json.Converters
{
    using KeRui.Json;
    using System;
    using System.Drawing;

    public class HtmlColorConverter : JsonConverter
    {
        public override bool CanConvert(Type valueType)
        {
            return typeof(Color).IsAssignableFrom(valueType);
        }

        public override void WriteJson(JsonWriter writer, object value)
        {
            writer.WriteValue(ColorTranslator.ToHtml((Color) value));
        }
    }
}

